/******************************************************************************
** @file	test_cm_dblitemanager.cpp
** @author  Joel Chuca
**
** @date	Sep 01, 2010
**
** @desc	This testSuite tests the creating of database and tables.
*			
******************************************************************************/

#include "unit--/unit--.h"
#include "cm_dblitemanager.h"
#include "cm_registryitem.h"
#include "wmi_registry.h"
#include "wmi_value.h"
#include "wmi_result.h"
#include <vector>

using namespace unit_minus;

testSuite(CacheManager);

testCase(insertRegistryListTest, CacheManager)
{
    cout << "----- Start insertRegistryListTest -----" << endl;
    CM_DBLiteManager mng ;
    mng.initialize();

    WMI_Registry* reg1 = new WMI_Registry;

    reg1->setName(wstring(L"GNU"));
    reg1->setPath(wstring(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\GNU"));
    WMI_Value value1;
    value1.setName(wstring(L"name01"));
    value1.setType(wstring(L"type01"));

    WMI_Value value2;
    value2.setName(wstring(L"name01"));
    value2.setType(wstring(L"type01"));

    reg1->addValue(value1);
    reg1->addValue(value2);
    
    WMI_Registry* reg2 = new WMI_Registry;
    reg2->setName(wstring(L"EFGH"));
    reg2->setPath(wstring(L"PC\\HKEY_LOCAL_MACHINE\\SOFTWARE\\EFGH"));

    WMI_Registry* reg3 = new WMI_Registry;
    reg3->setName(wstring(L"ABCD"));
    reg3->setPath(wstring(L"PC\\HKEY_LOCAL_MACHINE\\SOFTWARE\\ABCD"));
    
    reg1->addRegistry(reg2);
    reg1->addRegistry(reg3);

    WMI_Result<WMI_Registry> result;
    result.setWRegistry(reg1);
    
    CM_RegistryItem regItem;
    int res = regItem.saveRegistries(1, result);
    assertTrue(res == 1);
    cout << "-------- End insertRegistryListTest ------" << endl;
}

testCase(getRegistryListTest, CacheManager)
{
    cout << "----- Start getRegistryListTest -----" << endl;
    WMI_Result<WMI_Registry> result;
    
    CM_RegistryItem regItem;
    int res = regItem.getRegistries(1, result);
    assertTrue(res == 1);
    cout << "-------- End getRegistryListTest ------" << endl;
}